<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('志愿者黑名单列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <!--搜索框-->
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>志愿者编号：</p>
                                <input type="text" name="volunteerCode"/>
                            </li>
                            <li>
                                <p>姓名：</p>
                                <input type="text" name="volunteerName"/>
                            </li>
                            <li>
                                <p>部门：</p>
                                <select name="sectorId">
                                    <option value="">所有</option>
                                    <option th:each="item:${sectorList}"
                                            th:value="${item.sectorId}"
                                            th:text="${item.sectorName}">
                                    </option>
                                </select>
                            </li>
                            <li>
                                <p>学院名称：</p>
                                <select name="academyId">
                                    <option value="">所有</option>
                                    <option th:each="item:${academyList}"
                                            th:value="${item.academyId}"
                                            th:text="${item.academyName}">
                                    </option>
                                </select>
                            </li>
                            <li>
                                <p>最高学历：</p>
                                <select name="volunteerDegree" th:with="type=${@dict.getType('degree')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}"
                                            th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}">
                                    </option>
                                </select>
                            </li>
                            <li class="select-time">
                                <p>入队时间：</p>
                                <input type="text" class="time-input" id="startTime" style="width: 133px" placeholder="请选择开始时间" name="params[beginVolunteerDate]"/>
                                <span>至</span>
                                <input type="text" class="time-input" id="endTime" style="width: 133px" placeholder="请选择结束时间" name="params[endVolunteerDate]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--组件操作-->
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="team:advisermanage:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>

            <!--志愿者黑名单列表-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">
                    <thead>
                    <tr>
                        <th data-checkbox="true"></th>
                        <th data-formatter="fm_rowIndex" data-align="center">序号</th>
                        <th data-field="volunteerCode" data-align="center">志愿者编号</th>
                        <th data-field="volunteerName" data-align="center">姓名</th>
                        <th data-field="sexName" data-formatter="fm_sex" data-align="center">性别</th>
                        <th data-field="sectorName" data-align="center">部门</th>
                        <th data-field="dutiesName" data-align="center">担任职务</th>
                        <th data-field="volunteerAcademy" data-align="center">学院名称</th>
                        <th data-field="volunteerProfession" data-align="center">专业</th>
                        <th data-field="volunteerNo" data-align="center">学号</th>
                        <th data-field="volunteerDegree" data-formatter="fm_degree" data-align="center">学历</th>
                        <th data-field="volunteerDate" data-align="center" data-formatter="fm_date">入队时间</th>
                        <th data-field="serveTime" data-align="center">服务时长</th>
                        <th data-field="serveTimes" data-align="center">服务次数</th>
                        <th data-formatter="fm_commands" data-width="280px" data-align="center">操作</th>
                    </tr>
                    </thead>
                </table>
            </div>

        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('team:blacklist:edit')}]];            //编辑
        var detailFlag = [[${@permission.hasPermi('team:blacklist:detail')}]];        //详情
        var moveFlag = [[${@permission.hasPermi('team:blacklist:move')}]];            //移除
        var prefix = ctx + "vtsp/blacklist";                    //志愿者黑名单
        var sexData = [[${@dict.getType('sys_user_sex')}]];     //获取字典中的数据：性别
        var degreeData = [[${@dict.getType('degree')}]];        //获取字典中的数据：学历

        //初始化表格参数
        $(function()
        {
            var options =
                {
                    url: prefix + "/list",                  //志愿者黑名单页面
                    updateUrl: prefix + "/edit/{id}",       //编辑
                    exportUrl: prefix + "/export",          //导出
                    detailUrl: prefix + "/detail/{id}",     //详情
                    modalName: "志愿者黑名单信息",
                    uniqueId: "volunteerId"
                };
            $.table.init(options);
        });

        //格式化日期
        function fm_date(value, row ,index)
        {
            return dateFormat("YYYY-mm-dd", value);
        }

        //格式化数据字典：性别
        function fm_sex(value, row ,index)
        {
            return $.table.selectDictLabel(sexData, value);
        }
        //格式化数据字典：学历
        function fm_degree(value, row ,index)
        {
            return $.table.selectDictLabel(degreeData, value);
        }

        //操作按钮
        function fm_commands(value, row, index)
        {
            var actions = [];
            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.volunteerId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
            actions.push('<a class="btn btn-primary btn-xs' + detailFlag + '" href="javascript:void(0)" onclick="$.modal.openFull(\'' + '志愿者黑名单详情' + '\',\'' + prefix + '/detail/' + row.volunteerId + '\')"><i class="fa fa-search"></i>详情</a>');
            actions.push('<a class="btn btn-danger btn-xs ' + moveFlag + '" href="javascript:void(0)" onclick="removeBlacklist(\'' + row.volunteerId + '\')"><i class="fa fa-remove"></i>移除</a>');
            return actions.join('');
        }

        //移出黑名单
        function removeBlacklist(volunteerId)
        {
            //窗体确认
            $.modal.confirm("确定将该志愿者移出黑名单吗？",function()
            {
                //点击确认
                let moveUrl = prefix + "/move";
                let volunteerData = {"volunteerId":volunteerId};
                //上传信息
                $.operate.submit(moveUrl, "post", "json", volunteerData);
                $.modal.alertSuccess("操作成功！");
            });
        }
    </script>
</body>
</html>